Reputation: 10686
I have several npm
packages with client-side scripts I want to include to separate pages of my Nuxt.js project. I have tried to do that with:
<script>
export default {
head: {
script: [
{ src: "gojs/release/go.js", type: "text/javascript" }
]
},
// ...
}
</script>
but received 404 (Not Found)
error. What is correct way to do that?
Upvotes: 2
Views: 1953
Reputation: 138556
Normally, import
-ing the module (e.g., with import go from 'gojs'
) and using it in your code are all you need to do for the build to include that dependency. No need to add headers to load the NPM module.
Example in MyFoo.vue
:
<script>
import go from 'gojs'
export default {
mounted() {
const $ = go.GraphObject.make;
const myDiagram =
$(go.Diagram, "myDiagramDiv",
{
"undoManager.isEnabled": true
});
...
}
}
</script>
Upvotes: 1